
function on_login(){
	login_info = {}
	login_info['name'] = document.getElementById('name_id').value
	login_info['password'] = document.getElementById('password_id').value
	
	function on_login_response(response_string){
		if(response_string == '0'){
			alert('Wrong name or password')
			return
		}else{
			window.location.href = 'http://' + window.location.host + '/' + response_string
		}
	}

	initialize_ajax("/on_login?login_data=" + JSON.stringify(login_info), on_login_response)
}

function initialize(){

	login_button = '<a href="javascript:'
	login_button += 'on_login()" '
	login_button += ' class="pretty_button" style="margin-left:0px;line-height:30px;height:30px;margin-top:10px;"> Login </a>'

	content = '<table style="font-size:20pt; font-family: \'Oxygen\', sans-serif;">'
	content += '<tr>'
	content += 	'<td style="text-align:right;">Email</td>'
	content +=  '<td><input id=name_id type="text" maxlength="20" style="font-size:15pt"></td>'
	content += '</tr>'
	content += '<tr>'
	content += 	'<td style="text-align:right;">Password</td>'
	
	content +=  '<td><input id=password_id type="password" maxlength="20" style="font-size:15pt"></td>'
	content += '</tr>'
	content += '<tr>'
	content += 	'<td colspan=2 style="text-align:right;">' + login_button + '</td>'
	content += '</tr>'
	content += '</table>'

	document.getElementById('login_content').innerHTML = content
}

